package tx.bj12320.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import tx.bj12320.model.*;
import tx.bj12320.dao.*;
import tx.bj12320.service.*;
import tx.bj12320.vo.query.*;


@Entity
@Table(name = "BJ12320_SMS_INFO")
public class SmsInfo extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;

	//alias
	public static final String TABLE_ALIAS = "SmsInfo";
	public static final String ALIAS_SMS_INFO_ID = "smsInfoId";
	public static final String ALIAS_USER_INFO_ID = "userInfoId";
	public static final String ALIAS_SELL_PHONE = "sellPhone";
	public static final String ALIAS_INFO_CONTENT = "infoContent";
	public static final String ALIAS_SEND_DATETIME = "sendDatetime";
	public static final String ALIAS_IS_GLOBAL = "isGlobal";
	public static final String ALIAS_IS_SENT = "isSent";

	//date formats
	public static final String FORMAT_SEND_DATETIME = DATE_FORMAT;


	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * smsInfoId       db_column: SMS_INFO_ID
     */
	
	private Long smsInfoId;
    /**
     * userInfoId       db_column: USER_INFO_ID
     */
	
	private Long userInfoId;
    /**
     * sellPhone       db_column: SELL_PHONE
     */
	@Length(max=100)
	private java.lang.String sellPhone;
    /**
     * infoContent       db_column: INFO_CONTENT
     */
	@Length(max=4000)
	private java.lang.String infoContent;
    /**
     * sendDatetime       db_column: SEND_DATETIME
     */
	
	private java.util.Date sendDatetime;
    /**
     * isGlobal       db_column: IS_GLOBAL
     */
	
	private Long isGlobal;
    /**
     * isSent       db_column: IS_SENT
     */
	
	private Long isSent;
	//columns END


	public SmsInfo(){
	}

	public SmsInfo(
		Long smsInfoId
	){
		this.smsInfoId = smsInfoId;
	}



	public void setSmsInfoId(Long value) {
		this.smsInfoId = value;
	}

	@Id	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="BJ12320_SMS_INFO_SEQU")
    @SequenceGenerator(name="BJ12320_SMS_INFO_SEQU",allocationSize=1,initialValue=1, sequenceName="BJ12320_SMS_INFO_SEQU")
	@Column(name = "SMS_INFO_ID", unique = true, nullable = false, insertable = true, updatable = true, length = 0)
	public Long getSmsInfoId() {
		return this.smsInfoId;
	}

	@Column(name = "USER_INFO_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getUserInfoId() {
		return this.userInfoId;
	}

	public void setUserInfoId(Long value) {
		this.userInfoId = value;
	}

	@Column(name = "SELL_PHONE", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getSellPhone() {
		return this.sellPhone;
	}

	public void setSellPhone(java.lang.String value) {
		this.sellPhone = value;
	}

	@Column(name = "INFO_CONTENT", unique = false, nullable = true, insertable = true, updatable = true, length = 4000)
	public java.lang.String getInfoContent() {
		return this.infoContent;
	}

	public void setInfoContent(java.lang.String value) {
		this.infoContent = value;
	}

	@Transient
	public String getSendDatetimeString() {
		return DateConvertUtils.format(getSendDatetime(), FORMAT_SEND_DATETIME);
	}
	public void setSendDatetimeString(String value) {
		setSendDatetime(DateConvertUtils.parse(value, FORMAT_SEND_DATETIME,java.util.Date.class));
	}

	@Column(name = "SEND_DATETIME", unique = false, nullable = true, insertable = true, updatable = true, length = 7)
	public java.util.Date getSendDatetime() {
		return this.sendDatetime;
	}

	public void setSendDatetime(java.util.Date value) {
		this.sendDatetime = value;
	}

	@Column(name = "IS_GLOBAL", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getIsGlobal() {
		return this.isGlobal;
	}

	public void setIsGlobal(Long value) {
		this.isGlobal = value;
	}

	@Column(name = "IS_SENT", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getIsSent() {
		return this.isSent;
	}

	public void setIsSent(Long value) {
		this.isSent = value;
	}


	private UserInfo userInfo;
	public void setUserInfo(UserInfo userInfo){
		this.userInfo = userInfo;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "USER_INFO_ID",nullable = false, insertable = false, updatable = false) 
	})
	public UserInfo getUserInfo() {
		return userInfo;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("SmsInfoId",getSmsInfoId())
			.append("UserInfoId",getUserInfoId())
			.append("SellPhone",getSellPhone())
			.append("InfoContent",getInfoContent())
			.append("SendDatetime",getSendDatetime())
			.append("IsGlobal",getIsGlobal())
			.append("IsSent",getIsSent())
			.toString();
	}

	public int hashCode() {
		return new HashCodeBuilder()
			.append(getSmsInfoId())
			.toHashCode();
	}

	public boolean equals(Object obj) {
		if(obj instanceof SmsInfo == false) return false;
		if(this == obj) return true;
		SmsInfo other = (SmsInfo)obj;
		return new EqualsBuilder()
			.append(getSmsInfoId(),other.getSmsInfoId())
			.isEquals();
	}
}

